import React, { Component } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import * as actions from '../../actions/index'

class HomeIndex extends Component {

    state = {
        page: 0,
        pageNum: 10
    }

    componentDidMount() {
        this.props.get_Data()
    }

    render() { 
        let { data } = this.props
        console.log(data)
        return (
            <div>
                {
                    data && data.length ? data.map((item,index) => {
                        return (
                            <div key={index}>
                                <img src={item.img} alt='' />
                                <span>{item.title}</span>
                            </div>
                        )
                    }) : ''
                }
            </div>
        )
    }
}

let mapStateToProps = ({homeReducer}) => {
    return {
        ...homeReducer
    }
}

let mapDispatchToProps = (dispatch) => bindActionCreators(actions, dispatch)
 
export default connect(mapStateToProps, mapDispatchToProps)(HomeIndex)